import { useParams } from "react-router-dom"
import { Card, Descriptions, Space } from "antd";
import { useEffect, useState } from "react";
import { getOrderById } from "@/api/order";
export default function Show() {
    const { id } = useParams();

    const [orderInfo, setorderInfo] = useState<any>({});
    const [patient, setpatient] = useState<any>({ param: {} });
    useEffect(() => {
        const getorderInfoAsync = async () => {
            const result: any = await getOrderById(Number(id));
            console.log(result);
            setorderInfo(result.orderInfo);
            setpatient(result.patient);
        }
        getorderInfoAsync();
    }, [])
    return (
        <Card>
            <Space direction="vertical" style={{ width: "100%" }}>
                <Descriptions title="订单信息" column={2} bordered>
                    <Descriptions.Item label="订单交易号">{orderInfo.outTradeNo}</Descriptions.Item>
                    <Descriptions.Item label="医院名称">{orderInfo.hosname}</Descriptions.Item>
                    <Descriptions.Item label="科室名称">{orderInfo.depname}</Descriptions.Item>
                    <Descriptions.Item label="医生职称">{orderInfo.title}</Descriptions.Item>
                    <Descriptions.Item label="安排时间">{orderInfo.fetchTime}</Descriptions.Item>
                    <Descriptions.Item label="就诊人">{orderInfo.patientName}</Descriptions.Item>
                    <Descriptions.Item label="预约号序">{orderInfo.number}</Descriptions.Item>
                    <Descriptions.Item label="服务费(元)">{orderInfo.amount}</Descriptions.Item>
                    <Descriptions.Item label="订单状态">{orderInfo.orderStatusString}</Descriptions.Item>
                    <Descriptions.Item label="创建时间">{orderInfo.createTime}</Descriptions.Item>
                    <Descriptions.Item label="更新时间">{orderInfo.updateTime}</Descriptions.Item>
                </Descriptions>
                <Descriptions title="用户信息" column={2} bordered>
                    <Descriptions.Item label="姓名">{orderInfo.name}</Descriptions.Item>
                    <Descriptions.Item label="身份证号">{orderInfo.certificatesNo}</Descriptions.Item>
                    <Descriptions.Item label="住址">{patient.address}</Descriptions.Item>
                    <Descriptions.Item label="出生日期">{patient.birthdate}</Descriptions.Item>
                    <Descriptions.Item label="所在城市">{patient.param.cityString}</Descriptions.Item>
                    <Descriptions.Item label="所在区">{patient.param.districtString}</Descriptions.Item>
                    <Descriptions.Item label="完整地址">{patient.param.fullAddress}</Descriptions.Item>
                    <Descriptions.Item label="省份">{patient.param.provinceString}</Descriptions.Item>
                    <Descriptions.Item label="省份">{(patient.sex === 0) ? ("男") : ("女")}</Descriptions.Item>
                </Descriptions>
            </Space>

        </Card>
    )
}